function PwdMgr()
{
   var mgr = CC["@mozilla.org/passwordmanager;1"].createInstance();
   this.pmgr = mgr.QueryInterface(Components.interfaces.nsIPasswordManager);
   this.pmgri = mgr.QueryInterface(Components.interfaces.nsIPasswordManagerInternal);
}

PwdMgr.prototype.removeUser = function (server)
{
    var uri =  {value:""};
    var olduser =  {value:""};
    var oldpass = {value:""}; 
    if(server != "")
    try 
    {
		this.pmgri.findPasswordEntry(server, null, null, uri, olduser, oldpass);
    }
    catch (e)
	{ 
		return;
	}
    
    if(olduser.value !="")
		this.pmgr.removeUser(server, olduser.value);
}

PwdMgr.prototype.saveLoginInfo = function (server, username, password)
{
    this.pmgr.addUser(server,  username, password);
}

PwdMgr.prototype.loadLogin = function( url, username, password)
{
  var uri =  {value:""};
  var user =  {value:""};
  var pass = {value:""}; 
  if(url != ""){
	try {
	    this.pmgri.findPasswordEntry(url, null, null, uri, user, pass);
  	    username.value = user.value;
  	    password.value = pass.value;
	}catch(e){
	}
  }
}

function getRDFLiteral(ds, source, predicate)
{
	var target = ds.GetTarget(source, predicate, true).QueryInterface(CI.nsIRDFLiteral)
	if (target)
	{
		return target.Value;
	}
	return null;
}

function getDate()
{
	var dt = new Date();
	var d = "0" + dt.getDate();
	var m = "0" + dt.getMonth();
	return d.substr(d.length - 2) + m.substr(m.length - 2) + dt.getFullYear()
}

function getTime(dt){
	var stamp = new Date(dt);
	var min = "0" + stamp.getMinutes() + "]";
	var hr = "0" + stamp.getHours() + ":";
 	return "[" + hr.substr(hr.length - 3) + min.substr(min.length - 3);
}

function getDiv(text){
	var div = document.createElement ("html:span");
	div.appendChild(document.createTextNode(text));
	return div;
}

